/*=============================================================
* 	Copyright (C) 2024 USTC All rights reserved.
* 	
* 	filename : main.cpp
* 	Author: Wei Jinsong
* 	Mail: vitus@mainl.ustc.edu.cn
* 	Date 2024-05-13
* 	Abstract 
* 		
*
=============================================================*/

// #include "systemc.h"
#include "utils.h"
#include "testbench.h"
#include "nn.h"
#include "systemc.h"
#include "nlohmann/json.hpp"

using namespace std;
using namespace sc_core;
// using json = nlohmann::json;
sc_trace_file *SC_TF;
string wave_file;

int sc_main(int argc, char* argv[])
{
    
    // assert((argc>=2)&&"argc>=2");
    cout << "create" <<endl;
    cout << argv[1] << endl;
    cout << argv[2] <<endl;
    wave_file = string(argv[1])+"/fs_wave";
    SC_TF = sc_create_vcd_trace_file(wave_file.c_str());
    cout << SC_TF << endl;

    string nn_type = argv[2];


    if (nn_type=="snn") {
        BaseNetwork nn("newtwork", argv[1]);
        cout << "start BaseNetwork Demo" << endl;
        sc_start(1000000, SC_NS);
        cout << "done" << endl;
        sc_close_vcd_trace_file(SC_TF);

    }else if (nn_type=="fsnn") {
        FSNetwork nn("fs_newtwork", argv[1]);
        cout << "start FS Demo" << endl;
        sc_start(1000000, SC_NS);
        cout << "done" << endl;
        sc_close_vcd_trace_file(SC_TF);
        nn.print_spike_sta(cout);
    }else if (nn_type=="dvs") {
        DVSNetwork nn("dvs_newtork", argv[1]);
        cout << "start DVS Demo" << endl;
        sc_start(2500000, SC_NS);
        cout << "done" << endl;
        sc_close_vcd_trace_file(SC_TF);
        nn.print_spike_sta(cout);
    }
    // BaseNetwork nn("newtwork", argv[1]);
    // FSNetwork nn("fs_newtwork", argv[1]);
    // DVSNetwork nn("dvs_newtork", argv[1]);
    

    return 0;
}

